%% Carbon Taxes Around the World: Cooperation, Strategic Interactions, and Spillovers
% IMF Economic Review
% Alessandro Moro and Valerio Nispi Landi
% Replication files
% This file plots the IRFs

clc; clear all; close all; 
SAVE=0;

load path1
load path2
load par
PAPER=1;         % if 1, you plot for the paper, 0 you plot for the presentation

Tfull=length(c1)-1;         % path length
T=60+1;


% Define objects for plotting

usedfont='Georgia';
FigW=25;
FigH=FigW;

%% Variables



cellvarspap=    {'gdp','r','e',...
                 'kB_zd', 'kG_zd','bY', ...
                 'kB_zu', 'kG_zu','s'
                 };
              
cellvarlabelspap={'GDP','Bond rate','Emissions (GtC)',...
                'AE brown FDI assets','AE green FDI assets','AE bond net assets',...
                'AE brown FDI liabilities','AE green FDI liabilities','AE real depreciation'
                 };

cellvarspap2=    {'c', 'kB', 'kG',...
                  'uip','tbY','x'};

cellvarlabelspap2={'Consumption','Domestic B capital','Domestic G capital',...
                   'UIP premium (EME-AE)', 'Trade balance','Gl. pollution (GtC)'};

cellvarspap1b=    {'gdp','gdpz','kB_zd',...
                    'mu','muz','kG_zd',...
                    'r','rz','kB_zu',...
                    'bY','s','kG_zu'
                 };
cellvarlabelspap1b={'AE GDP','EME GDP','AE brown FDI assets',...
                    'AE abatement','EME abatement','AE green FDI assets',...
                    'AE bond rate','EME bond rate','AE brown FDI liabilities',...
                    'AE bond net assets','AE real depreciation','AE green FDI liabilities'
                 };


cellvarspres=    {'gdp','r','e',...
                 'kB_zd', 'kG_zd','bY', ...
                 'kB_zu', 'kG_zu','s'
                 };
              

cellvarlabelspres={'GDP','Bond rate','Emissions (GtC)',...
                'AE capital in EME B firms','AE capital in EME G firms','AE bond net assets',...
                'EME capital in AE B firms','EME capital in AE G firms','AE real depreciation'
                 };    
cellvarspres2=    {'gdp','kB_zd','kG_zd'...
                  'gdpz','kB_zu','kG_zu'...
                   'r','rz','bY'
                 };
cellvarlabelspres2={'AE GDP','AE capital in EME B firms','AE capital in EME G firms',...
                    'EME GDP','EME capital in AE B firms','EME capital in AE G firms',...
                    'AE bond rate','EME bond rate','AE bond net assets'
                    
                 };
           
%%
if PAPER==1           

% 1)
figure;
set(gcf,'color', 'white',...
        'PaperUnits','centimeters','PaperSize',[FigW FigH],...
        'PaperPosition',[0,0,FigW,FigH],'PaperPositionMode','manual',...
        'Units','centimeters',...
        'Position',[0,0,FigW,FigH]);


for j=1:9
subplot(3,3,j)
plottanda1=eval(['100*' cellvarspap{j} '1' ';']); 
plot(2020:1:2020+T-1,plottanda1(1:T),'Linewidth',2);
if j==1
hold on
plot(2020:1:2020+T-1,100*gdpz1(1:T),'r:','Linewidth',3);
leg=legend('AE','EME','Location','southoutside','Orientation','horizontal','Box','off','Fontsize',16);   
leg.Position(1) = 0.385;
leg.Position(2) = 0.01;
elseif j==2
hold on
plot(2020:1:2020+T-1,100*rz1(1:T),'r:','Linewidth',3);
elseif j==3
hold on
plot(2020:1:2020+T-1,100*ez1(1:T),'r:','Linewidth',3);
end
title(cellvarlabelspap{j},'Fontsize',16,'fontweight','bold')
axis tight
xticks([2020 2040 2060 2080])
ax = gca;
ax.FontSize = 16; 
ax.YAxis.Exponent = 0;
end

if SAVE==1 && SYM==0
print('-dpng','-r500',['./figures/trans1_asymGam.png'])
end

% 2
figure;
set(gcf,'color', 'white',...
        'PaperUnits','centimeters','PaperSize',[FigW 0.85*FigH],...
        'PaperPosition',[0,0,FigW,0.85*FigH],'PaperPositionMode','manual',...
        'Units','centimeters',...
        'Position',[0,0,FigW,0.85*FigH]);

for j=1:6
subplot(2,3,j)
plottanda1=eval(['100*' cellvarspap2{j} '1' ';']); 
plot(2020:1:2020+T-1,plottanda1(1:T),'Linewidth',2);
if j==1
hold on
plot(2020:1:2020+T-1,100*cz1(1:T),'r:','Linewidth',3);
leg=legend('AE','EME','Location','southoutside','Orientation','horizontal','Box','off','Fontsize',16);   
leg.Position(1) = 0.385;
leg.Position(2) = 0.005;
elseif j==2
hold on
plot(2020:1:2020+T-1,100*kB_zz1(1:T),'r:','Linewidth',3);
elseif j==3
hold on
plot(2020:1:2020+T-1,100*kG_zz1(1:T),'r:','Linewidth',3);
end
title(cellvarlabelspap2{j},'Fontsize',16,'fontweight','bold')
axis tight
xticks([2020 2040 2060 2080])
ax = gca;
ax.FontSize = 16; 
ax.YAxis.Exponent = 0;
end

if SAVE==1 && SYM==0
print('-dpng','-r500',['./figures/trans2_asymGam.png'])
end

%3


figure;
set(gcf,'color', 'white',...
        'PaperUnits','centimeters','PaperSize',[FigW FigH],...
        'PaperPosition',[0,0,FigW,FigH],'PaperPositionMode','manual',...
        'Units','centimeters',...
        'Position',[0,0,FigW,FigH]);

    nF=12;
    nr=4;

for j=1:nF
subplot(nr,3,j)
plottanda1=eval(['100*' cellvarspap1b{j} '1' ';']); 
plottanda2=eval(['100*' cellvarspap1b{j} '2' ';']); 
plot(2020:1:2020+T-1,plottanda1(1:T),'Linewidth',2);
hold on
plot(2020:1:2020+T-1,plottanda2(1:T),'r:','Linewidth',3);
title(cellvarlabelspap1b{j},'Fontsize',16,'fontweight','bold')
axis tight
xticks([2020 2040 2060 2080])
ax = gca;
ax.FontSize = 16; 
ax.YAxis.Exponent = 0;
end
leg=legend('AE optimal, EME baseline','AE optimal, EME optimal','Location','southoutside','Orientation','horizontal','Box','off','Fontsize',16);   
leg.Position(1) = 0.20;
leg.Position(2) = 0.01;
if SAVE==1 && SYM==1
print('-dpng','-r500',['./figures/trans1b.png'])
elseif SAVE==1 && SYM==0
print('-dpng','-r500',['./figures/trans1b_asymGam.png'])
end


%% Presentation
elseif PAPER==0           
           
figure;
set(gcf,'color', 'white',...
        'PaperUnits','centimeters','PaperSize',[1.5*FigW FigH],...
        'PaperPosition',[0,0,1.5*FigW,FigH],'PaperPositionMode','manual',...
        'Units','centimeters',...
        'Position',[0,0,1.5*FigW,FigH]);

for j=1:9
subplot(3,3,j)
plottanda1=eval(['100*' cellvarspres{j} '1' ';']); 
plot(2020:1:2020+T-1,plottanda1(1:T),'Linewidth',4);
if j==1
hold on
plot(2020:1:2020+T-1,100*gdpz1(1:T),'r:','Linewidth',4);
leg=legend('AE','EME','Location','southoutside','Orientation','horizontal','Box','off','Fontsize',20);   
leg.Position(1) = 0.385;
leg.Position(2) = 0.01;
elseif j==2
hold on
plot(2020:1:2020+T-1,100*rz1(1:T),'r:','Linewidth',4);
elseif j==3
hold on
plot(2020:1:2020+T-1,100*ez1(1:T),'r:','Linewidth',4);
end
title(cellvarlabelspres{j},'Fontsize',18,'fontweight','bold')
axis tight
xticks([2020 2040 2060 2080])
ax = gca;
ax.FontSize = 18; 
ax.YAxis.Exponent = 0;
end

if SAVE==1
print('-dpng','-r500',['./figures/trans_pres.png'])
end

figure;
set(gcf,'color', 'white',...
        'PaperUnits','centimeters','PaperSize',[1.5*FigW FigH],...
        'PaperPosition',[0,0,1.5*FigW,FigH],'PaperPositionMode','manual',...
        'Units','centimeters',...
        'Position',[0,0,1.5*FigW,FigH]);



for j=1:9
subplot(3,3,j)
plottanda1=eval(['100*' cellvarspres2{j} '1' ';']); 
plottanda2=eval(['100*' cellvarspres2{j} '2' ';']); 
plot(2020:1:2020+T-1,plottanda1(1:T),'Linewidth',4);
hold on
plot(2020:1:2020+T-1,plottanda2(1:T),'r:','Linewidth',4);
title(cellvarlabelspres2{j},'Fontsize',18,'fontweight','bold')
axis tight
xticks([2020 2040 2060 2080])
ax = gca;
ax.FontSize = 18; 
ax.YAxis.Exponent = 0;
end
leg=legend('AE optimal, EME baseline','Nash','Location','southoutside','Orientation','horizontal','Box','off','Fontsize',20);   
leg.Position(1) = 0.35;
leg.Position(2) = 0.01;
if SAVE==1
print('-dpng','-r500',['./figures/trans_pres2.png'])
end
end
